<!-- 优势总括 -->
<template>
	<view class="advantage">
		<view class="flex alignCenter tip">
			<view class="flex alignCenter">
				<image src="https://image.alhelp.net/uploads/20231104/f5a50463b8dd7a1b1ea25f211c8ffd65.png" mode="widthFix"></image>
				<view class="font14 color999">两句话概括你的优势！</view>
			</view>
			<view class="font14 bold num"><text class="colorMain font18">2</text>/3</view>
		</view>

		<view class="cardItem">
			<view class="title-box">
				<view class="input-box flex alignCenter">
					<image src="/static/image/toolbox/edit.png"></image>
					<input class="font14" placeholder="控制在8个字以内" maxlength="8" v-model="forms.info1"/>
				</view>
				
				<view class="input-box flex alignCenter">
					<image src="/static/image/toolbox/edit.png"></image>
					<input class="font14" placeholder="控制在8个字以内" maxlength="8" v-model="forms.info2"/>
				</view>
			</view>
			
		</view>
		<view class="btns flex alignCenter font16">
			<view class="btn1 flex alignCenter" @click="handleLast">
				<view class="icons flex alignCenter"><image src="../../../static/leftIcon.png" mode="widthFix"></image></view>
				上一步 
			</view>
			<view class="btn2 flex alignCenter" @click="handleNext">
				下一步 
				<view class="icons flex alignCenter"><image src="../../../static/rightIcon.png" mode="widthFix"></image></view>
			</view>
		</view>
	</view>
</template>

<script>
	import { addEducation,eduDetail,editEdu,getEdu } from "@/api/mine.js"
	import { uploadFile,chooseImg,previewImg} from "@/utils/common.js"
	export default {
		data() {
			return {
				forms: {
					info1: '',
					info2: '',
				},
				param: {},
				backDelta: '',//返回页面数
				diploma:2
			};
		},
		onLoad(option) {
			if(option.backDelta){
				this.backDelta = option.backDelta;
			}
			this.diploma=option.diploma?option.diploma:2
			console.log('参数',option,this.diploma,this.backDelta)
			if(option.param){
				this.param = JSON.parse(option.param);
				if(this.param.tags){
					// let infos = this.param.tags.split(',');
					this.forms.info1 = this.param.tags[0]?this.param.tags[0]:'';
					this.forms.info2 = this.param.tags[1]?this.param.tags[1]:'';
				}
			}else{
				this.getDetail();
			}
		},
		methods:{
			// 详情（编辑时调用）
			getDetail(){
				getEdu({diploma: this.diploma}).then(res=>{
					if(res.code == 100000 && res.data){
						this.param={
							diploma:this.diploma, 
							graduationYear:res.data.graduationYear,//毕业年份
							schoolCode:res.data.schoolCode,
							schoolName:res.data.schoolName,
							majorCode:res.data.majorCode,
							majorName:res.data.majorName,
							imgUrl:res.data.imgUrl,
							introduce: res.data.introduce,
							tags: res.data.tags,
							fileUrls: res.data.fileUrls,
							id: res.data.id
						};
						if(res.data.tags){
							// let infos = this.param.tags.split(',');
							this.forms.info1 = res.data.tags[0]?res.data.tags[0]:'';
							this.forms.info2 = res.data.tags[1]?res.data.tags[1]:'';
						}
					}
				})
			},
			
			// 上一步
			handleLast(){
				uni.navigateBack(1)
			},
			
			//下一步
			handleNext(){
				if(!this.forms.info1 || !this.forms.info2){
					return uni.showToast({
						title: '请用两句话概括你的优势',
						icon: 'none'
					})
				}
				console.log(this.forms.toString());
				this.param.tags = [this.forms.info1,this.forms.info2];
				console.log(this.param);
				uni.navigateTo({
					url:`/pages/send/lookFor/postgraduate/enrollment/info?param=${JSON.stringify(this.param)}&backDelta=${this.backDelta}`
				})
			}
		}
	}
</script>
<style lang="scss">
page{
	background-color:$pageBgColor;
}
</style>
<style lang="scss" scoped>
.advantage{
	padding: 0 30rpx 120rpx;
	box-sizing: border-box;
	.tip{
		padding: 60rpx 44rpx 40rpx 44rpx;
		box-sizing: border-box;
		justify-content: space-between;
		// margin:0 0 60rpx 0;
		image{
			width:92rpx;
			height:84rpx;
			margin:0 20rpx 0 0;
		}
		.num{
			margin-left: 20rpx;
		}
	}
	.cardItem{
		.title-box{
			background: #fff;
			.input-box{
				margin: 0 30rpx;
				justify-content: flex-start;
				border-bottom: 1px dotted rgba(242, 242, 242, 1);
				height: 108rpx;
				input{
					margin: 0 10rpx;
					width: 100%;
				}
				image{
					margin-right: 10rpx;
					width: 36rpx;
					height: 36rpx;
					
				}
			}
			
			.input-box:last-child{
				border: none
			}
		}
	}
	
	.btns{
		background: #F7DD5E;
		color: #333;
		text-align: center;
		font-size: 14px;
		border-radius: 40rpx;
		box-shadow: 0 0 10rpx 0 rgba(0,0,0,.2);
		position: fixed;
		bottom: 30rpx;
		z-index: 10;
		right: 0;
		margin-right: 94rpx;
		.btn1,.btn2{
			height: 48px;
			line-height: 48px;
			background: #F7DD5E;
			color: #333;
			border-radius: 42px;
			text-align: center;
			width: 280rpx;
			margin: 0 auto;	
			justify-content: center;
			.icons{
				width: 32rpx;
				height: 32rpx;
				border-radius: 50%;
				background: #fff;
				text-align: center;
				image{
					width: 32rpx;
					height: 32rpx;
				}
			}
		}
		.btn1{
			background: #72819A;
			border-radius: 40rpx;
			border-top-right-radius: 0px;
			border-bottom-right-radius: 0px;
			.icons{
				margin-right: 36rpx;
			}
		}
		.btn2{
			background: $colorMain;
			border-radius: 40rpx;
			border-top-left-radius: 0px;
			border-bottom-left-radius: 0px;
			.icons{
				margin-left: 36rpx;
			}
		}
	}
}

</style>
